如何在Unity创建文件时自动生成命名空间 |
您所在的位置:网站首页 › unity 添加脚本 › 如何在Unity创建文件时自动生成命名空间 |
在 Unity Editor 创建脚本或者相关文件时里面都会有一些预设的内容 比方说 MonoBehaviour using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewMonoBehaviour : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } }但是唯独不会生成命名空间, 当然可以使用别的代码编辑器相关的工具去达成以上的目的, 但对于喜欢直接在 Editor 下创建文件的小伙伴来说就显得不那么友好了 直接修改安装目录下的模板这是因为在 Editor 的安装目录 %EDITOR_PATH%\Data\Resources\ScriptTemplates 里面存在着一些模板 Windows: C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates Mac: /Applications/Unity/Editor/Data/Resources/ScriptTemplates Linux: /home/Unity/Editor/Data/Resources/ScriptTemplates using System.Collections; using System.Collections.Generic; using UnityEngine; #ROOTNAMESPACEBEGIN# public class #SCRIPTNAME# : MonoBehaviour { // Start is called before the first frame update void Start() { #NOTRIM# } // Update is called once per frame void Update() { #NOTRIM# } } #ROOTNAMESPACEEND#当然你可以直接修改这个模板, 但这只能你自己使用, 这并不 Unity, 所以采用第二种方案直接在各自工程目录下创建合适项目的模板 在工程里面自定义首先 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |